@extends('public.layouts')
@section('style')
    <meta name="_token" content="{{ csrf_token() }}"/>
    <style>
        .task-table-th {
            text-align: center;
        }

        .task-table-td {
            text-align: center;
        }

        .keyword {
            max-width: 300px;
        }

        .keyword-btn {
            max-width: 80px;
        }

        .patent-list-th {
            text-align: center;
        }

        .patent-list-td {
            text-align: center;
        }

        .trademark-list-th {
            text-align: center;
        }

        .trademark-list-td {
            text-align: center;
        }

        #patent-list {
            max-height: 400px;
            overflow-y: auto;
        }

        #trademark-list {
            max-height: 400px;
            overflow-y: auto;
        }


    </style>
    <link rel="stylesheet" href="{{asset('admin_assets/css/bootstrap-datetimepicker.min.css')}}">
    <link rel="stylesheet" href="{{url('css/search.css')}}">
    <link rel="stylesheet" href="{{url('css/task.css')}}">
@stop
@section('content')
    <div class="content-wrapper" style="background-color: white">
        <section class="content">
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="box box-info"
                         style="padding-top: 0px;margin-top: 0px;border-top: 0px;border-bottom: solid 1px #009aff;">
                        <div class="box-body" style="">
                            <div class="row">
                                <div class="col-lg-2 col-md-2 col-sm-12 col-xs-12" style="margin-top: 1%">
                                    <a href="#" title="返回首页" style="float: left"><i class="fa fa-home fa-2x"
                                                                                    style="width: 100%;color: #009aff">
                                        </i></a>
                                    <a href="{{url('user/work/index')}}"><span
                                                style="font-size: 20px;float: left;color: #009aff">&nbsp;工作台</span></a>
                                    <div class="clear"></div>
                                </div>
                                {{--<div class="col-lg-2 col-md-2 col-sm-12 col-xs-12  col-lg-offset-8 col-md-offset-8">--}}
                                    {{--<form action="{{url('user/work/indexSearch')}}" method="post"--}}
                                          {{--enctype="multipart/form-data" class="search">--}}
                                        {{--{{csrf_field()}}--}}
                                        {{--<input type="search" id="search-input" name="search">--}}
                                        {{--<button type="submit" class="fa fa-search fa-lg"></button>--}}
                                    {{--</form>--}}
                                {{--</div>--}}
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            @include('public/alert')
            <div class="row">
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #37A8F4">
                        <div class="inner" style="background: #37A8F4">
                            <h3>{{$count[0]}}</h3>
                            <p>专利数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/patent_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myPatent')}}" class="small-box-footer"
                           style="background: #009aff">详情<i class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #8BC44A">
                        <div class="inner" style="background: #8BC44A">
                            <h3>{{$count[1]}}</h3>
                            <p>商标数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/trademark_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myTrademark')}}" class="small-box-footer" style="background: #72aa49">详情<i
                                    class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #FFBA00">
                        <div class="inner" style="background: #FFBA00">
                            <h3>{{$count[2]}}</h3>
                            <p>版权数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/copyright_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myCopyright')}}" style="background: #c69200" class="small-box-footer">详情<i
                                    class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
                <div class="col-lg-3 col-md-6 col-sm-12 col-xs-12">
                    <div class="small-box bg-aqua" style="background: #F4521E">
                        <div class="inner" style="background: #F4521E">
                            <h3>{{$count[3]}}</h3>
                            <p>项目数量</p>
                        </div>
                        <div class="icon">
                            <img src="{{asset('admin_assets/img/project_icon.png')}}"
                                 style="width: 100px;height: 100px;margin-left: 0;margin-top: -20px">
                        </div>
                        <a href="{{url('user/mine/myProject')}}" style="background: #e14b1c" class="small-box-footer">详情<i
                                    class="fa fa-arrow-circle-right"></i></a>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-left: 10px">
                <form class="form-inline" action="{{url('user/work/certainSearch')}}" method="post"
                      enctype="multipart/form-data">
                    {{csrf_field()}}
                    <div class="form-group">
                        <label for="exampleInputName2">申请人</label>
                        <input type="text" class="form-control" name="applyer" id="exampleInputName2" placeholder="申请人">
                    </div>
                    <div class="form-group">
                        <label for="exampleInputEmail2">公司</label>
                        <input type="text" class="form-control" name="company" id="exampleInputEmail2" placeholder="公司">
                    </div>
                    <label for="exampleInputName2">任务类别</label>
                    <select class="form-control" name="wordtype">
                        <option value="0" >首次任务</option>
                        <option value="1">续费任务</option>
                    </select>
                    <label for="exampleInputName2">类型</label>

                    <select class="form-control" name="type" >
                        @foreach($firstType as $k =>$c)
                            <option value="{{$k+1}}">{{$c}}</option>
                        @endforeach
                    </select>
                    <div class="form-group">
                        <label for="exampleInputName2">发起时间</label>
                        <input type="date" name="time" class="form-control" id="exampleInputName2" >
                    </div>
                    <label for="exampleInputName2">任务状态</label>
                    <select class="form-control" name="state">
                        <option value="0">未结算</option>
                        <option value="1">未接单</option>
                        <option value="2">操作中</option>
                        <option value="3">结案</option>
                        <option value="4">通过</option>
                    </select>
                    <label for="exampleInputName2">任务等级</label>
                    <select class="form-control" name="task">
                        <option value="0">普通任务</option>
                        <option value="1">重要任务</option>
                        <option value="2">紧急任务</option>
                    </select>
                    <div class="form-group">
                        <label for="exampleInputName2">执行人</label>
                        <input type="text" name="actioner" class="form-control" id="exampleInputName2" placeholder="执行人">
                    </div>
                    <button type="submit" class="btn btn-default">搜索</button>
                </form>
            </div>
            <div class="row">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <table class="table table-bordered">
                            <thead>
                            <tr>
                                <th class="task-table-th">任务编号</th>
                                <th class="task-table-th">申请人</th>
                                <th class="task-table-th">公司</th>
                                <th class="task-table-th">任务类别</th>
                                <th class="task-table-th">类型</th>
                                <th class="task-table-th">任务发起时间</th>
                                <th class="task-table-th">任务状态</th>
                                <th class="task-table-th">任务等级</th>
                                <th class="task-table-th">执行人</th>
                            </tr>
                            </thead>
                            <tbody>
                            @if($product->isEmpty())
                                <tr>
                                    <td class="task-table-td" colspan="9"><h3 align="center">暂无数据</h3></td>
                                </tr>
                            @else
                                @php($i=0)
                                @foreach($product as $k =>$c)
                                    @php($v =$c['Product'])
                                    @if(!empty($c['FirstType'])&&(!empty($v)))
                                        <tr>
                                            <td class="task-table-td" style="vertical-align: middle">{{++$i}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{$v['applicant']}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{$v['company']}}</td>
                                            <td class="task-table-td" style="vertical-align: middle">
                                                @if($c['is_renew']==0)
                                                    首次任务
                                                @else
                                                    续费任务
                                                @endif
                                            </td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{$c['FirstType']['name']}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">{{date("Y-m-d",strtotime($v['created_at']))}}</td>
                                            <td class="task-table-td task_flow"
                                                style="vertical-align: middle;cursor: pointer"
                                                data-toggle="modal"
                                                data-target="#task_flowModal"
                                                data-pid="{{$c['product_id']}}"
                                                data-progressid="{{$c['id']}}"
                                                data-second_type_id="{{$c['second_type_id']}}"

                                            >{{config('config.product_state')[$c['state']]}}</td>
                                            <td class="task-table-td"
                                                style="vertical-align: middle">
                                                @if(is_null($v['level']))
                                                    暂无数据
                                                @else
                                                    {{config('config.product_level')[$v['level']]}}
                                                @endif
                                            </td>
                                            <td class="task-table-td" style="vertical-align: middle">
                                                @if(empty($c['agent']))
                                                    暂无
                                                @else
                                                    {{$c['agent']}}
                                                @endif
                                            </td>
                                        </tr>
                                    @endif
                                @endforeach
                            @endif
                            </tbody>
                        </table>
                        <div class="">
                            {!! $product->links() !!}
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-top: 2%">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <div id="trademark-list" class="box">
                            <div class="box-header">
                                <h3 class="box-title" style="vertical-align: middle;margin-top: 10px">商标列表</h3>
                                <form action="#" method="post" onsubmit="return false;" enctype="multipart/form-data"
                                      style="width: 70%;height: 40px;float: right">
                                    <button type="submit" onclick="getTrademark();" class="btn btn-info keyword-btn"
                                            style="background: #009aff;width: 15%;float: right;">查询
                                    </button>
                                    <input type="text" id="trademarkSearch" class="form-control keyword"
                                           placeholder="申请人/名称/申请人/内部编码/案件状态"
                                           style="width: 85%;border-radius: 5px;float: right">
                                </form>
                            </div>
                            <div class="box-body no-padding">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th class="trademark-list-th">#</th>
                                        <th class="trademark-list-th">名称</th>
                                        <th class="trademark-list-th">申请人</th>
                                        <th class="trademark-list-th">申请公司</th>
                                        <th class="trademark-list-th">申请时间</th>
                                        <th class="trademark-list-th">状态</th>
                                    </tr>
                                    </thead>
                                    <tbody id="trademarkSearchList">
                                    <tr>
                                        <td class="trademark-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
            <div class="row" style="margin-top: 2%">
                <div class="col-lg-12 col-md-12 col-sm-12 col-xs-12">
                    <div class="table-responsive">
                        <div id="patent-list" class="box">
                            <div class="box-header">
                                <h3 class="box-title" style="vertical-align: middle;margin-top: 10px">专利列表</h3>
                                <form action="#" method="post" onsubmit="return false;" enctype="multipart/form-data"
                                      style="width: 70%;height: 40px;float: right">
                                    <button type="submit" onclick="getPatent();" class="btn btn-info keyword-btn"
                                            style="background: #009aff;width: 15%;float: right;">查询
                                    </button>
                                    <input type="text" id="patentSearch" class="form-control keyword"
                                           placeholder="申请人/名称/申请人/内部编码/案件状态"
                                           style="width: 85%;border-radius: 5px;float: right">
                                </form>
                            </div>
                            <div class="box-body no-padding">
                                <table class="table table-bordered">
                                    <thead>
                                    <tr>
                                        <th class="patent-list-th">#</th>
                                        <th class="patent-list-th">名称</th>
                                        <th class="patent-list-th">申请人</th>
                                        <th class="patent-list-th">专利类型</th>
                                        <th class="patent-list-th">申请时间</th>
                                        <th class="patent-list-th">法律状态</th>
                                    </tr>
                                    </thead>
                                    <tbody id="patentSearchList">
                                    <tr>
                                        <td class="patent-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>
                                    </tr>
                                    </tbody>
                                </table>
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </section>
        @include('public/taskFlowModal')
    </div>
@stop
@section('javascript')
    <script src="{{asset('admin_assets/js/bootstrap-datetimepicker.min.js')}}"></script>
    <script src="{{asset('js/ip.js')}}"></script>
    <script>
        $(".form_datetime").datetimepicker({
            format: "yyyy-mm-dd hh:ii:ss",
            autoclose: true,
            todayBtn: true,
            minuteStep: 10,
            language: "en"
        });

        function getTrademark() {
            $.ajax({
                url: '{{url('user/work/juheSearchTrademarkList')}}',
                type: 'post',
                dataType: 'json',
                data: {
                    'keyword': $('#trademarkSearch').val()
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success: function (data) {
                    console.log(data);
                    var e = $('#trademarkSearchList');
                    e.empty();
                    if (data == '0') {
                        e.append('<tr>');
                        e.append('<td class="trademark-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>');
                        e.append('</tr>');
                    } else {
                        var url = window.location.href;
                        var index = url.lastIndexOf("\/");
                        url = url.substring(0, index + 1);
                        url += 'juheSearchTrademarkDetail';
                        for (var i = 0, size = data.length; i < size; i++) {
                            var item = data[i];
                            e.append('<tr>');
                            e.append('<td class="trademark-list-td patent-id">' + (i + 1) + '</td>');
                            e.append('<td class="trademark-list-td patent-name"><a href="' + url + '?intCls=' + item['intCls'] + '&regNo=' + item['regNo'] + ' " target=_blank>' + item['tmName'] + '</a></td>');
                            e.append('<td class="trademark-list-td patent-apply">' + item['applicantCn'] + '</td>');
                            e.append('<td class="trademark-list-td patent-company">' + item['agent'] + '</td>');
                            e.append('<td class="trademark-list-td patent-date">' + item['regDate'] + '</td>');
                            e.append('<td class="trademark-list-td patent-state">' + item['currentStatus'] + '</td>');
                            e.append('</tr>');
                        }
                    }
                }

            });
        }

        function getPatent() {
            $.ajax({
                url: '{{url('user/work/juheSearchPatent')}}',
                type: 'post',
                dataType: 'json',
                data: {
                    'q': $('#patentSearch').val()
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success: function (data) {
                    // console.log(data);
                    var e = $('#patentSearchList');
                    e.empty();
                    if (data == '0') {
                        e.append('<tr>');
                        e.append('<td class="patent-list-td" colspan="6"><h3 align="center">暂无数据</h3></td>');
                        e.append('</tr>');
                    } else {
                        var url = window.location.href;
                        var index = url.lastIndexOf("\/");
                        url = url.substring(0, index + 1);
                        url += 'juheSearchPatentInfo';
                        for (var i = 0, size = data.length; i < size; i++) {
                            var item = data[i];
                            e.append('<tr>');
                            e.append('<td class="patent-list-td patent-id">' + (i + 1) + '</td>');
                            e.append('<td class="patent-list-td patent-name"><a href="' + url + '?id=' + item['id'] + '" target="_blank">' + item['title'] + '</a></td>');
                            e.append('<td class="patent-list-td patent-apply">' + item['applicant'] + '</td>');
                            e.append('<td class="patent-list-td patent-company">' + item['type'] + '</td>');
                            e.append('<td class="patent-list-td patent-date">' + item['applicationDate'] + '</td>');
                            e.append('<td class="patent-list-td patent-state">' + item['legalStatus'] + '</td>');
                            e.append('</tr>');
                        }
                    }
                }

            });
        }


        $(".task_flow").click(function () {
            var product_id = $(this).attr("data-pid");
            var progressid = $(this).attr("data-progressid");
            var second_type_id = $(this).attr("data-second_type_id");
            $.ajax({
                url: '{{url('user/operate/getProjectSchedule')}}',
                type: 'post',
                dataType: 'json',
                data: {
                    'pid': product_id,
                    'p_id': progressid,
                    's_id': second_type_id
                },
                headers: {
                    'X-CSRF-TOKEN': $('meta[name="_token"]').attr('content')
                },
                success: function (data) {

                    // console.log(data);

                    var e = $('#task_progress');
                    e.empty();
                    if (data.length) {
                        for (var i = 0, size = data.length; i < size; i++) {


                            var item = data[i];

                            if (item['state'] == 1) {
                                e.append('  <div class="l_content_box" >\n' +
                                    '            <div class="a_tm_info" >\n' +
                                    '                <div class="l_left">\n' +
                                    '                    <div>\n' +
                                    '                        <p class="l_green">' + item['time'].split(' ')[0] + '</p>\n' +
                                    '                        <p class="l_green">' + item['time'].split(' ')[1] + '</p>\n' +
                                    '                    </div>\n' +
                                    '                </div>\n' +
                                    '                <div class="l_center l_green" >\n' +
                                    '                    <i class="fa fa-check-circle fa-2x"></i>\n' +
                                    '                </div>\n' +
                                    '                <div class="l_right" style="">\n' +
                                    '                    <div>\n' +
                                    '                        ' +
                                    '                        <p class="l_green l_quickInformation" title="' + item['operate'] + '">' + item['operate'] + '</p>\n' +
                                    '                    </div>\n' +
                                    '                </div>\n' +
                                    '            </div>\n' +
                                    '        </div>');
                            }
//                          else if(i==1){
//                              e.append('  <div class="l_content_box">\n' +
//                                  '            <div class="a_tm_info" >\n' +
//                                  '                <div class="l_left">\n' +
//                                  '                    <div>\n' +
//                                  '                        <p class="l_orange">'+item['time'].split(' ')[0]+'</p>\n' +
//                                  '                        <p class="l_orange">'+item['time'].split(' ')[1]+'</p>\n' +
//                                  '                    </div>\n' +
//                                  '                </div>\n' +
//                                  '                <div class="l_center l_orange" >\n' +
//                                  '                    <i class="fa fa-check-circle fa-2x"></i>\n' +
//                                  '                </div>\n' +
//                                  '                <div class="l_right" style="">\n' +
//                                  '                    <div>\n' +
//                                  '                        ' +
//                                  '                        <p class="l_orange l_quickInformation" title="'+item['operate']+'">'+item['operate']+'</p>\n' +
//                                  '                    </div>\n' +
//                                  '                </div>\n' +
//                                  '            </div>\n' +
//                                  '        </div>');
//                          }
                            else {
                                e.append('  <div class="l_content_box">\n' +
                                    '            <div class="a_tm_info" >\n' +
                                    '                <div class="l_left">\n' +
                                    '                    <div>\n' +
                                    '                        <p class="l_gray">' + item['time'].split(' ')[0] + '</p>\n' +
                                    '                        <p class="l_gray">' + item['time'].split(' ')[1] + '</p>\n' +
                                    '                    </div>\n' +
                                    '                </div>\n' +
                                    '                <div class="l_center l_gray" >\n' +
                                    '                    <i class="fa fa-check-circle fa-2x"></i>\n' +
                                    '                </div>\n' +
                                    '                <div class="l_right" style="">\n' +
                                    '                    <div>\n' +
                                    '                        ' +
                                    '                        <p class="l_gray l_quickInformation" title="' + item['operate'] + '">' + item['operate'] + '</p>\n' +
                                    '                    </div>\n' +
                                    '                </div>\n' +
                                    '            </div>\n' +
                                    '        </div>');
                            }

                        }
                    } else {

                    }
                }

            });

        });
    </script>
@stop
